package com.study.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import com.study.dao.entity.MovieUser;

@RestController
public class MovieUserController {
	
	@Autowired
	RestTemplate restTemplate;
	
	@GetMapping("/simple/{id}")
	public MovieUser selectById(@PathVariable("id") int id) {
		MovieUser movieUser = restTemplate.getForObject("http://127.0.0.1:8080/simple/1", MovieUser.class);
		//使用ribbon负载均衡时，可以直接使用VIP=virtual IP=serviceID=spring.application.name，@LoadBalance
//		MovieUser movieUser = restTemplate.getForObject("http://sunxj-microservice-provider-user/simple/1", MovieUser.class);
		return movieUser;
	}

}
